<?php 
include ('configure.php');
include("class.db.php");

session_start();
$val=0;

$msql  = new Db;
$msql->connect();

$user_name=htmlspecialchars($_POST['user_name'],ENT_QUOTES);
$pass=md5($_POST['password']);

$sql="SELECT user_name, password FROM login WHERE user_name='".$user_name."'";
$result=$msql->execute($sql);
$row=mysql_fetch_array($result);
if(mysql_num_rows($result)>0)
{
    
    //compare the password
    if(strcmp($row['password'],$pass)==0)
    {
        //now set the session from here if needed
        $_SESSION['u_name']=$user_name;
        
    }  
    if('admin'==$_SESSION['u_name'])
    {
        $val=1; //login with root
    }
        
    if('user'==$_SESSION['u_name'])
    {
        $val=2; //login with user
    }

}
echo $val;
?>
